/*
 * Ext JS Library 2.1
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function() {
    var form = new Ext.form.FormPanel({
        baseCls: 'x-plain',
        layout:'absolute',
        url:'save.jsp',
        defaultType: 'textfield',

        items: [
            new Ext.form.FieldSet({
                title: 'Contact Information',
                autoHeight: true,
                defaultType: 'textfield',
                items: [{
                        fieldLabel: 'First Name',
                        name: 'first',
                        width:190
                    }, {
                        fieldLabel: 'Last Name',
                        name: 'last',
                        width:190
                    }, {
                        fieldLabel: 'Company',
                        name: 'company',
                        width:190
                    }]
            })
        ],
        buttons: [{
            text: 'Send',
			handler:function(){
				form.getForm().submit({ 
                  url:'save.jsp',
                  method:'post', 
                  params:'', 
                  success:function(form,action){
                  Ext.Msg.alert('operation','success'); 
                  // Ext.Msg.alert('operation',action.result.data); 
                  this.disabled=false;
                  },
                  failure:function(){
                       Ext.Msg.alert('operation','failure');
                       this.disabled=false;
                  }
                  });
				windows.hide();
			}
        },{
            text: 'Cancel',
			handler:function(){
				windows.hide();
			}
        }]
    });

    var windows = new Ext.Window({
        title: 'Resize Me',
        width: 500,
        height:300,
        minWidth: 300,
        minHeight: 200,
        layout: 'fit',
        plain:true,
        bodyStyle:'padding:5px;',
        buttonAlign:'center',
        items: form
    });
    windows.show();
});